/**
 */
package wcomm_v1.impl;

import java.util.Collection;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.common.util.EList;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;

import org.eclipse.emf.ecore.util.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.InternalEList;

import wcomm_v1.Messsage2Message;
import wcomm_v1.SimpleComponentDefinition;
import wcomm_v1.Wcomm_v1Package;
import wcomm_v1.XTA;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Simple Component Definition</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link wcomm_v1.impl.SimpleComponentDefinitionImpl#getBehaviour <em>Behaviour</em>}</li>
 *   <li>{@link wcomm_v1.impl.SimpleComponentDefinitionImpl#getMsgBindings <em>Msg Bindings</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class SimpleComponentDefinitionImpl extends ComponentDefinitionImpl implements SimpleComponentDefinition
{
  /**
   * The cached value of the '{@link #getBehaviour() <em>Behaviour</em>}' containment reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getBehaviour()
   * @generated
   * @ordered
   */
  protected XTA behaviour;

  /**
   * The cached value of the '{@link #getMsgBindings() <em>Msg Bindings</em>}' containment reference list.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getMsgBindings()
   * @generated
   * @ordered
   */
  protected EList<Messsage2Message> msgBindings;

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  protected SimpleComponentDefinitionImpl()
  {
    super();
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  protected EClass eStaticClass()
  {
    return Wcomm_v1Package.Literals.SIMPLE_COMPONENT_DEFINITION;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public XTA getBehaviour()
  {
    return behaviour;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetBehaviour(XTA newBehaviour, NotificationChain msgs)
  {
    XTA oldBehaviour = behaviour;
    behaviour = newBehaviour;
    if (eNotificationRequired())
    {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, Wcomm_v1Package.SIMPLE_COMPONENT_DEFINITION__BEHAVIOUR, oldBehaviour, newBehaviour);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
    return msgs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setBehaviour(XTA newBehaviour)
  {
    if (newBehaviour != behaviour)
    {
      NotificationChain msgs = null;
      if (behaviour != null)
        msgs = ((InternalEObject)behaviour).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - Wcomm_v1Package.SIMPLE_COMPONENT_DEFINITION__BEHAVIOUR, null, msgs);
      if (newBehaviour != null)
        msgs = ((InternalEObject)newBehaviour).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - Wcomm_v1Package.SIMPLE_COMPONENT_DEFINITION__BEHAVIOUR, null, msgs);
      msgs = basicSetBehaviour(newBehaviour, msgs);
      if (msgs != null) msgs.dispatch();
    }
    else if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, Wcomm_v1Package.SIMPLE_COMPONENT_DEFINITION__BEHAVIOUR, newBehaviour, newBehaviour));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public EList<Messsage2Message> getMsgBindings()
  {
    if (msgBindings == null)
    {
      msgBindings = new EObjectContainmentEList<Messsage2Message>(Messsage2Message.class, this, Wcomm_v1Package.SIMPLE_COMPONENT_DEFINITION__MSG_BINDINGS);
    }
    return msgBindings;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs)
  {
    switch (featureID)
    {
      case Wcomm_v1Package.SIMPLE_COMPONENT_DEFINITION__BEHAVIOUR:
        return basicSetBehaviour(null, msgs);
      case Wcomm_v1Package.SIMPLE_COMPONENT_DEFINITION__MSG_BINDINGS:
        return ((InternalEList<?>)getMsgBindings()).basicRemove(otherEnd, msgs);
    }
    return super.eInverseRemove(otherEnd, featureID, msgs);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public Object eGet(int featureID, boolean resolve, boolean coreType)
  {
    switch (featureID)
    {
      case Wcomm_v1Package.SIMPLE_COMPONENT_DEFINITION__BEHAVIOUR:
        return getBehaviour();
      case Wcomm_v1Package.SIMPLE_COMPONENT_DEFINITION__MSG_BINDINGS:
        return getMsgBindings();
    }
    return super.eGet(featureID, resolve, coreType);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @SuppressWarnings("unchecked")
  @Override
  public void eSet(int featureID, Object newValue)
  {
    switch (featureID)
    {
      case Wcomm_v1Package.SIMPLE_COMPONENT_DEFINITION__BEHAVIOUR:
        setBehaviour((XTA)newValue);
        return;
      case Wcomm_v1Package.SIMPLE_COMPONENT_DEFINITION__MSG_BINDINGS:
        getMsgBindings().clear();
        getMsgBindings().addAll((Collection<? extends Messsage2Message>)newValue);
        return;
    }
    super.eSet(featureID, newValue);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eUnset(int featureID)
  {
    switch (featureID)
    {
      case Wcomm_v1Package.SIMPLE_COMPONENT_DEFINITION__BEHAVIOUR:
        setBehaviour((XTA)null);
        return;
      case Wcomm_v1Package.SIMPLE_COMPONENT_DEFINITION__MSG_BINDINGS:
        getMsgBindings().clear();
        return;
    }
    super.eUnset(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public boolean eIsSet(int featureID)
  {
    switch (featureID)
    {
      case Wcomm_v1Package.SIMPLE_COMPONENT_DEFINITION__BEHAVIOUR:
        return behaviour != null;
      case Wcomm_v1Package.SIMPLE_COMPONENT_DEFINITION__MSG_BINDINGS:
        return msgBindings != null && !msgBindings.isEmpty();
    }
    return super.eIsSet(featureID);
  }

} //SimpleComponentDefinitionImpl
